﻿@model ECSE6770.Models.EditProfileModel
@{
    if (ViewBag.Title == null)
    {
        ViewBag.Title = "Confirm Contact Information";
    }
        
    string sa = System.Configuration.ConfigurationManager.AppSettings["SuperAdminName"];
    
    //check our temp data, to see if this page is being requested in a special order
    EditProfileParams parameters = TempData["EditProfileParams"] as EditProfileParams;
    if (parameters != null)
    {
        parameters.ApplyToViewBag(ViewBag);   
    }
}

@if (ViewBag.IntroText != null)
{
    <p>@ViewBag.IntroText</p>
}

@using (Html.BeginForm())
{
    @Html.ValidationSummary(true, "Please correct the errors below and try again.")
    <div>
        <fieldset>
            <legend>Contact Information</legend>
            @if (User.IsInRole("Admin"))
            {
                <div class="editor-label">
                    User name
                </div>
                <div class="editor-field">
                    @Html.TextBoxFor(m => m.UserName, new { disabled = "disabled" })
                </div>
            }
            <div class="editor-label">
                @Html.LabelForWithReq(m => m.FirstName)
            </div>
            <div class="editor-field">
                @Html.TextBoxFor(m => m.FirstName)
                @Html.ValidationMessageFor(m => m.FirstName)
            </div>
            <div class="editor-label">
                @Html.LabelForWithReq(m => m.LastName)
            </div>
            <div class="editor-field">
                @Html.TextBoxFor(m => m.LastName)
                @Html.ValidationMessageFor(m => m.LastName)
            </div>
            <div class="editor-label">
                @Html.LabelForWithReq(m => m.Title)
            </div>
            <div class="editor-field">
                @Html.TextBoxFor(m => m.Title)
                @Html.ValidationMessageFor(m => m.Title)
            </div>
            <div class="editor-label">
                @Html.LabelForWithReq(m => m.EmailAddress)
            </div>
            <div class="editor-field">
                @Html.TextBoxFor(m => m.EmailAddress)
                @Html.ValidationMessageFor(m => m.EmailAddress)
            </div>
            
            <div class="editor-label">
                @Html.LabelForWithReq(m => m.PhoneNumber)
            </div>
            <div class="editor-field">
                @Html.TextBoxFor(m => m.PhoneNumber, new { @class = "phone" })
                @Html.ValidationMessageFor(m => m.PhoneNumber)
            </div>
            <div class="editor-label">
                @Html.LabelForWithReq(m => m.Fax)
            </div>
            <div class="editor-field">
                @Html.TextBoxFor(m => m.Fax, new { @class = "phone" })
                @Html.ValidationMessageFor(m => m.Fax)
            </div>

            <h4>Organization</h4>
            <div class="editor-label">
                @Html.LabelForWithReq(m => m.OrganizationName)
            </div>
            <div class="editor-field">
                @Html.TextBoxFor(m => m.OrganizationName)
                @Html.ValidationMessageFor(m => m.OrganizationName)
            </div>
            <div class="editor-label">
                @Html.LabelForWithReq(m => m.JobTitle)
            </div>
            <div class="editor-field">
                @Html.TextBoxFor(m => m.JobTitle)
                @Html.ValidationMessageFor(m => m.JobTitle)
            </div>
            <div class="editor-label">
                @Html.LabelForWithReq(m => m.OrganizationCountry)
            </div>
            <div class="editor-field">
                @Html.CountryDropDownFor(m => m.OrganizationCountry)
                @Html.ValidationMessageFor(m => m.OrganizationCountry)
            </div>
            <div class="editor-label">
                @Html.LabelForWithReq(m => m.OrganizationAddress)
            </div>
            <div class="editor-field">
                @Html.TextAreaFor(m => m.OrganizationAddress, 3, 40, null)
                @Html.ValidationMessageFor(m => m.OrganizationAddress)
            </div>

            <div class="horiz">
                <div class="item">
                    @Html.LabelForWithReq(m => m.OrganizationCity)
                    @Html.TextBoxFor(m => m.OrganizationCity)
                </div>
                <div class="item">
                    @Html.LabelForWithReq(m => m.OrganizationState)
                    @Html.StateDropDownFor(m => m.OrganizationState)
                </div>
                <div class="item">
                    @Html.LabelForWithReq(m => m.OrganizationZip)
                    @Html.TextBoxFor(m => m.OrganizationZip)
                </div>
                <div class="item val" style="width: 270px;">
                    @Html.ValidationMessageFor(m => m.OrganizationCity)
                    @Html.ValidationMessageFor(m => m.OrganizationState)
                    @Html.ValidationMessageFor(m => m.OrganizationZip)
                </div>
            </div>
            @if (User.IsInRole("Admin") && !Model.IsSuperAdmin)
            {
                Html.RenderPartial("EditRoles", Model);
                <input type="hidden" id="BindModelAs" name="BindModelAs" value="@ViewBag.BindModelAs" />
            }
            <p class="buttons">
                <input type="submit" value="Submit" />
            </p>
        </fieldset>
    </div>
}